// 装饰元素分类
export const decorationCategories = {
  stickers: {
    cute: { id: 'cute', name: '可爱', icon: '🌸' },
    minimal: { id: 'minimal', name: '简约', icon: '✨' },
    business: { id: 'business', name: '商务', icon: '💼' },
    nature: { id: 'nature', name: '自然', icon: '🌿' },
    food: { id: 'food', name: '美食', icon: '🍜' },
  },
  frames: {
    simple: { id: 'simple', name: '简单', icon: '⬜' },
    fancy: { id: 'fancy', name: '精美', icon: '🖼️' },
    modern: { id: 'modern', name: '现代', icon: '🎯' },
  },
  shapes: {
    basic: { id: 'basic', name: '基础', icon: '⭕' },
    abstract: { id: 'abstract', name: '抽象', icon: '🔷' },
    decorative: { id: 'decorative', name: '装饰', icon: '💫' },
  },
};

// 装饰元素数据
export const decorationItems = {
  stickers: {
    cute: [
      { id: 'cute-heart', type: 'sticker', category: 'cute', name: '爱心', emoji: '❤️', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'cute-star', type: 'sticker', category: 'cute', name: '星星', emoji: '⭐', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'cute-flower', type: 'sticker', category: 'cute', name: '花朵', emoji: '🌸', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'cute-rainbow', type: 'sticker', category: 'cute', name: '彩虹', emoji: '🌈', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
    ],
    minimal: [
      { id: 'minimal-dot', type: 'sticker', category: 'minimal', name: '圆点', emoji: '⚪', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'minimal-sparkle', type: 'sticker', category: 'minimal', name: '闪光', emoji: '✨', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'minimal-star', type: 'sticker', category: 'minimal', name: '星星', emoji: '★', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
    ],
    business: [
      { id: 'business-check', type: 'sticker', category: 'business', name: '对勾', emoji: '✓', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'business-briefcase', type: 'sticker', category: 'business', name: '公文包', emoji: '💼', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'business-chart', type: 'sticker', category: 'business', name: '图表', emoji: '📊', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
    ],
    nature: [
      { id: 'nature-leaf', type: 'sticker', category: 'nature', name: '叶子', emoji: '🌿', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'nature-tree', type: 'sticker', category: 'nature', name: '树木', emoji: '🌳', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'nature-flower', type: 'sticker', category: 'nature', name: '花', emoji: '🌺', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
    ],
    food: [
      { id: 'food-noodles', type: 'sticker', category: 'food', name: '面条', emoji: '🍜', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'food-cake', type: 'sticker', category: 'food', name: '蛋糕', emoji: '🍰', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'food-coffee', type: 'sticker', category: 'food', name: '咖啡', emoji: '☕', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
    ],
  },
  frames: {
    simple: [
      { id: 'frame-square', type: 'frame', category: 'simple', name: '方形', emoji: '⬜', scale: { min: 0.8, max: 1.2, default: 1 }, rotation: { min: 0, max: 0, default: 0 } },
      { id: 'frame-circle', type: 'frame', category: 'simple', name: '圆形', emoji: '⭕', scale: { min: 0.8, max: 1.2, default: 1 }, rotation: { min: 0, max: 0, default: 0 } },
    ],
    fancy: [
      { id: 'frame-heart', type: 'frame', category: 'fancy', name: '爱心', emoji: '💝', scale: { min: 0.8, max: 1.2, default: 1 }, rotation: { min: 0, max: 0, default: 0 } },
      { id: 'frame-star', type: 'frame', category: 'fancy', name: '星星', emoji: '⭐', scale: { min: 0.8, max: 1.2, default: 1 }, rotation: { min: 0, max: 0, default: 0 } },
    ],
    modern: [
      { id: 'frame-minimal', type: 'frame', category: 'modern', name: '简约', emoji: '▢', scale: { min: 0.8, max: 1.2, default: 1 }, rotation: { min: 0, max: 0, default: 0 } },
      { id: 'frame-geometric', type: 'frame', category: 'modern', name: '几何', emoji: '⬡', scale: { min: 0.8, max: 1.2, default: 1 }, rotation: { min: 0, max: 0, default: 0 } },
    ],
  },
  shapes: {
    basic: [
      { id: 'shape-circle', type: 'shape', category: 'basic', name: '圆形', emoji: '⭕', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'shape-square', type: 'shape', category: 'basic', name: '方形', emoji: '⬜', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'shape-triangle', type: 'shape', category: 'basic', name: '三角', emoji: '△', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
    ],
    abstract: [
      { id: 'shape-wave', type: 'shape', category: 'abstract', name: '波浪', emoji: '〰️', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'shape-spiral', type: 'shape', category: 'abstract', name: '螺旋', emoji: '🌀', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
    ],
    decorative: [
      { id: 'shape-sparkles', type: 'shape', category: 'decorative', name: '闪光', emoji: '✨', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
      { id: 'shape-stars', type: 'shape', category: 'decorative', name: '星星', emoji: '⋆', scale: { min: 0.5, max: 2, default: 1 }, rotation: { min: -180, max: 180, default: 0 } },
    ],
  },
};

// 获取指定类型和分类的装饰元素
export const getDecorationItems = (type, category) => {
  if (!category) {
    // 如果没有选择分类，返回该类型下所有分类的装饰元素
    const allItems = [];
    const typeItems = decorationItems[type];
    if (typeItems) {
      Object.values(typeItems).forEach(categoryItems => {
        allItems.push(...categoryItems);
      });
    }
    return allItems;
  }
  // 返回指定类型和分类的装饰元素
  return decorationItems[type]?.[category] || [];
};

// 获取指定类型的所有分类
export const getCategories = (type) => {
  return decorationCategories[type] || {};
};

// 获取指定ID的装饰元素
export const getDecorationById = (id) => {
  for (const type in decorationItems) {
    for (const category in decorationItems[type]) {
      const item = decorationItems[type][category].find(item => item.id === id);
      if (item) return item;
    }
  }
  return null;
};
